{{> warning}}
{{> error}}

<div class="row">
    <div class="col-md-12">
        <h2>Lookup</h2>
    </div>
</div>

{{#unless (or dcnsqlookupd.length nsqlookupd.length)}}
<div class="alert alert-warning">
    <h4>Notice</h4> nsqadmin is not configured with nsqlookupd hosts
</div>
{{else}}
<div class="row">
    <div class="col-md-4">
        {{#if dcnsqlookupd.length}}
        <table class="table table-bordered table-condensed">
            <tr>
                <th>DC</th>
                <th>nsqlookupd Host</th>
            </tr>
            {{#each dcnsqlookupd}}
            <tr>
                <td rowspan="{{lookupAddrs.length}}">{{dc}}</td>
                <td>{{lookupAddrs.[0]}} (configured)</td>
                {{#each lookupAddrs}}
                    {{#if @first}}
                    {{else}}
                        <tr><td>{{this}} (configured)</td></tr>
                    {{/if}}
                {{/each}}
            </tr>
            {{/each}}
            {{#each dcallnsqlookupds}}
            <tr>
                <td rowspan="{{lookupAddrs.length}}">{{dc}}</td>
                <td>
                {{lookupAddrs.[0]}}
                </td>
            </tr>
            {{#each lookupAddrs}}
                {{#if @first}}
                {{else}}
                    <tr>
                        <td>{{this}}</td>
                    </tr>
                {{/if}}
            {{/each}}
            {{/each}}
        </table>
        {{else}}
        <table class="table table-bordered table-condensed">
            <tr>
                <th>nsqlookupd Host</th>
            </tr>
            {{#each nsqlookupd}}
                <tr><td>{{this}} (configured)</td></tr>
            {{/each}}
            {{#each allnsqlookupds}}
                <tr><td>{{this}}</td></tr>
            {{/each}}
        </table>
        {{/if}}
    </div>
</div>

<div class="row">
    <div class="col-md-4">
        {{#if topics}}
        <div class="alert alert-info">
            Below is a tree of Topics that are currently inactive (i.e. not produced on any nsqd in the cluster but are present in the lookup data)
        </div>
        <ul>
            {{#each topics}}
            <li>
                <button class="btn-link red delete-topic-link" data-topic="{{name}}" style="padding: 0 6px; border: 0;">✘</button> <a class="link" href="/topics/{{name}}">{{name}}</a>
            </li>
            {{/each}}
        </ul>
        {{else}}
        <div class="alert alert-warning"><h4>Notice</h4>No inactive Topics</div>
        {{/if}}
    </div>
</div>
<div class="row">
    <div class="col-md-4">
        <form class="hierarchy">
            <legend>Create Topic</legend>
            <div class="alert alert-info">
                <p>This provides a way to setup a stream hierarchy
                before services are deployed to production.
            </div>
            <div class="form-group">
                Topic Name: <input type="text" name="topic" placeholder="Topic Name" required {{#if login}}{{else}}disabled{{/if}}><br>
                Partition Number: <input type="number" min=1 max=255 name="partition_num" style="width:100px;" placeholder="Partition Num" required {{#if login}}{{else}}disabled{{/if}}><br>
                Replica Number: <input type="number" min=1 max=5 name="replicator" style="width:100px;" placeholder="Replicator" required {{#if login}}{{else}}disabled{{/if}}><br>
                Sync Disk: <input type="number" min=0 max=50000 step=100 name="syncdisk" style="width:150px;" placeholder="SyncDisk(2000)" {{#if login}}{{else}}disabled{{/if}}><br>
                Retention Days: <input type="number" min=0 max=300 step=1 name="retention_days" style="width:150px;" placeholder="Retention(0)" {{#if login}}{{else}}disabled{{/if}}><br>
                Default Channel: <input type="text" name="channel" placeholder="Channel Name" required {{#if login}}{{else}}disabled{{/if}}><br>
                Is Topic Ordered: <input type="checkbox" name="orderedmulti" value="Is Ordered" {{#if login}}{{else}}disabled{{/if}}><br>
                Is Topic Extend: <input type="checkbox" name="extend" value="Is Topic extend" {{#if login}}{{else}}disabled{{/if}}><br>
            </div>
            <button class="btn btn-default" type="submit" {{#if login}}{{else}}disabled{{/if}}>Create</button>
        </form>
    </div>
</div>
{{/unless}}
